import React, { useEffect, useState } from 'react'
import { getFingerprint } from '@/util/fingerprint'
import ImagePreview from './ImagePreview'
import './index.less'
import { request } from 'util'
import { setUserToken } from 'util/token'
function UploadImage() {
    const [itemList, setItemList] = useState([])
    const getImageList = async () => {
        let data = await getFingerprint()
        console.log(data, '唯一指纹')
        request
            .post('https://dbyxs.top/api/login', {
                userName: '小楠',
                password: '1b56e3e7a66e2baa927971b1e2debae4',
            })
            .then((res) => {
                setUserToken(res.token)
            })
        request.get('https://dbyxs.top/api/imgs/list').then((res) => {
            console.log(res.message, '图片数据')
            setItemList(res?.message || [])
        })
    }
    useEffect(() => {
        getImageList()
    }, [])
    return (
        <>
            <div>
                {itemList.length > 0 && (
                    <ImagePreview
                        itemList={itemList?.map((item) => item.urlprd)}
                    ></ImagePreview>
                )}
            </div>
        </>
    )
}
export default UploadImage
